﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SalePartial.Model
{
    using Microsoft.VisualBasic;
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Data;
    using System.Diagnostics;
    using System.Data.SqlClient;

    public class XPInquiryEventInfo
    {
        // Methods
        public XPInquiryEventInfo()
        {
            this._inquiryID = Guid.Empty;
            this._buyerCompanyID = Guid.Empty;
            this._quoteID = Guid.Empty;
            this._vendorCompanyID = Guid.Empty;
            this._eventMessage = string.Empty;
            this._eventStatus = string.Empty;
            this._eventException = string.Empty;
            this._eventID = Guid.NewGuid();
            this._eventTime = DateTime.Now;
            this._eventCode = 0;
            this._eventType = 0;
            this._eventStatus = "0000";
            this._eventException = "";
            this._eventMessage = "";
            this._eventSequence = 0;
            this._importance = 0;
            this._isFlagged = false;
        }

        public XPInquiryEventInfo(SqlDataReader reader)
        {
            this._inquiryID = Guid.Empty;
            this._buyerCompanyID = Guid.Empty;
            this._quoteID = Guid.Empty;
            this._vendorCompanyID = Guid.Empty;
            this._eventMessage = string.Empty;
            this._eventStatus = string.Empty;
            this._eventException = string.Empty;
            this.LoadFromReader(reader);
        }

        //public XPInquiryEventInfo(Guid id)
        //{
        //    this._inquiryID = Guid.Empty;
        //    this._buyerCompanyID = Guid.Empty;
        //    this._quoteID = Guid.Empty;
        //    this._vendorCompanyID = Guid.Empty;
        //    this._eventMessage = string.Empty;
        //    this._eventStatus = string.Empty;
        //    this._eventException = string.Empty;
        //    SqlDataReader reader = XPInquiryEventUtility.SelectReader(id);
        //    if (reader.Read())
        //    {
        //        this.LoadFromReader(reader);
        //        reader.Close();
        //    }
        //    else
        //    {
        //        if (!reader.IsClosed)
        //        {
        //            reader.Close();
        //        }
        //        throw new ApplicationException("XPInquiryEventInfo does not exist.");
        //    }
        //}


        protected void LoadFromReader(SqlDataReader reader)
        {
            if ((!Information.IsNothing(reader) && !reader.IsClosed))
            {
                this._eventID = reader.GetGuid(0);
                this._inquiryID = reader.GetGuid(1);
                this._buyerCompanyID = reader.GetGuid(2);
                if (!reader.IsDBNull(3))
                {
                    this._quoteID = reader.GetGuid(3);
                }
                if (!reader.IsDBNull(4))
                {
                    this._vendorCompanyID = reader.GetGuid(4);
                }
                this._eventTime = reader.GetDateTime(5);
                if (!reader.IsDBNull(6))
                {
                    this._eventType = reader.GetInt32(6);
                }
                if (!reader.IsDBNull(7))
                {
                    this._eventSequence = reader.GetInt32(7);
                }
                if (!reader.IsDBNull(8))
                {
                    this._eventCode = reader.GetInt32(8);
                }
                if (!reader.IsDBNull(9))
                {
                    this._eventMessage = reader.GetString(9);
                }
                if (!reader.IsDBNull(10))
                {
                    this._eventStatus = reader.GetString(10);
                }
                this._importance = reader.GetInt32(11);
                this._isFlagged = reader.GetBoolean(12);
                if (!reader.IsDBNull(13))
                {
                    this._eventException = reader.GetString(13);
                }
            }
        }

     
        // Properties
        public Guid BuyerCompanyID
        {
            get { return this._buyerCompanyID; }
            set { this._buyerCompanyID = value; }
        }

        public int EventCode
        {
            get { return this._eventCode; }
            set { this._eventCode = value; }
        }

        public string EventException
        {
            get { return this._eventException; }
            set { this._eventException = value; }
        }

        public Guid EventID
        {
            get { return this._eventID; }
            set { this._eventID = value; }
        }

        public string EventMessage
        {
            get { return this._eventMessage; }
            set { this._eventMessage = value; }
        }

        public int EventSequence
        {
            get { return this._eventSequence; }
            set { this._eventSequence = value; }
        }

        public string EventStatus
        {
            get { return this._eventStatus; }
            set { this._eventStatus = value; }
        }

        public DateTime EventTime
        {
            get { return this._eventTime; }
            set { this._eventTime = value; }
        }

        public int EventType
        {
            get { return this._eventType; }
            set { this._eventType = value; }
        }

        public int Importance
        {
            get { return this._importance; }
            set { this._importance = value; }
        }

        public Guid InquiryID
        {
            get { return this._inquiryID; }
            set { this._inquiryID = value; }
        }

        public bool IsFlagged
        {
            get { return this._isFlagged; }
            set { this._isFlagged = value; }
        }

        public Guid QuoteID
        {
            get { return this._quoteID; }
            set { this._quoteID = value; }
        }

        public Guid VendorCompanyID
        {
            get { return this._vendorCompanyID; }
            set { this._vendorCompanyID = value; }
        }


        // Fields
        private Guid _buyerCompanyID;
        private int _eventCode;
        private string _eventException;
        private Guid _eventID;
        private string _eventMessage;
        private int _eventSequence;
        private string _eventStatus;
        private DateTime _eventTime;
        private int _eventType;
        private int _importance;
        private Guid _inquiryID;
        private bool _isFlagged;
        private Guid _quoteID;
        private Guid _vendorCompanyID;
    }


}
